﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DAL;
using QLCongNo.XuatHangform;

namespace QLCongNo.KhachHangform
{
    public partial class DSKhacHang : Form
    {
        KhachhangDAL kh = new KhachhangDAL();

        public DSKhacHang()
        {
            InitializeComponent();
        }
        public delegate void LayMA(string MyString);
        // khai báo 1 kiểu hàm delegate
        public LayMA MaKH;
        private void DSKhacHang_Load(object sender, EventArgs e)
        {
            
            dgv_KH.DataSource = kh.DanhsachKH();
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void txt_Timkiem_EditValueChanged(object sender, EventArgs e)
        {
            DataTable tb = new DataTable();

            tb = kh.TimKiemKH(txt_Timkiem.Text.ToString());
            dgv_KH.DataSource = tb;
        }

        private void txt_chon_Click(object sender, EventArgs e)
        {
            string ma, ten, maten;
            int i = dgv_KH.CurrentCell.RowIndex;
            ma = dgv_KH.Rows[i].Cells[0].Value.ToString();
            ten = dgv_KH.Rows[i].Cells[1].Value.ToString();
            maten = ma + " : " + ten;
            MaKH(maten);
            this.Close();
        }
    }
}
